{% extends "base.html" %}
{% block content %}
<div class="main">
    <div class="row">
		<div class="col-md-12">
			<div class="text-wrap">
				信息泄露检测
			</div>
		</div>
	</div>
    <div class="row">
		<div class="col-lg-12">

			<div class="input-group input-group-lg">
				<input type="text" id="url" class="form-control" aria-label="..." name="url">
				<div class="input-group-btn">
					<button type="button" id="information" class="btn btn-info btn-lg search-btn" aria-haspopup="true" aria-expanded="false"><b>检测</b></button>
				</div>
			</div>
		</div>
    </div>
    <div class="row main-panel">
        <div class="col-md-1"></div>
			<div class="col-md-10">
				<div id="color" class="panel panel-primary">

					<div class="panel-heading" id="result">
						结果：
					</div>
                </div>
            </div>
    </div>
    <div class="row">
		<div class="col-md-10">
			<div class="text-wrap">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
    var informationapi="/api/information";
    var url="";
    informationpocdict = {{data}}
	jindu=0

function request(url,type){
    $.post(informationapi,JSON.stringify({"url":url,"type":type}),function (results){
    	jindu+=1
        $("#result").html("当前检测:  "+informationpocdict[type]+"         扫描进度      "+toPercent(jindu/informationpocdict.length))
        if (toPercent(jindu/informationpocdict.length) == "100.0%"){$("#result").html("扫描完成           "+toPercent(jindu/informationpocdict.length))}
    	if(results.status){
    		$('#poc_'+type).remove()
    		$('<ul class="list-group" id="poc_'+type+'"><li class="list-group-item"><span class="text-primary">[+] 正在检测========>'+
    		informationpocdict[type]+'</span></li><li class="list-group-item"><span class="text-success">'+
    		results.pocresult+'</span></li></ul>').insertBefore("#poc_0")
    	}else{
    		$('#poc_'+type).html('<li class="list-group-item"><span class="text-primary">[+] 正在检测========>'+
    		informationpocdict[type]+'</span></li><li class="list-group-item"><span class="text-danger">[-]未发现异常： '+
    		informationpocdict[type]+'</span></li>')
    	}
    },"json");
}


$(function() {
    $('#information').click(function() {
    	jindu=0
        if(urlcheck()){
        	poclist='<div class="panel-heading" id="result">结果：</div>'
        	for(var i=0;i<informationpocdict.length;i++){
        		poclist+='<ul class="list-group" id="poc_'+i+'"><li class="list-group-item"><span class="text-primary">正在检测========>'+
        		informationpocdict[i]+'</span></li></ul>'
        		$('#color').html(poclist)
        		request(url,i)
        	}
        }
    });
});
</script>
{% endblock %}